/**
 * 获取顶部栏信息
 */
export async function getMenuButtonBoundingClientRect() {
	let dwObj = uni.getMenuButtonBoundingClientRect()
	let navHeight = (dwObj.top + dwObj.height + 5)
	dwObj.navHeight = navHeight
	return dwObj;
}



// 挑选targetObj有的字段进行浅合并
export function demandAssign(targetObj, sourceObj, isAll = false) {
	if (sourceObj === null || sourceObj === undefined) {
		return false;
	}
	if (isAll) {
		Object.assign(targetObj, sourceObj);
	} else {
		for (const key in targetObj) {
			if (Object.prototype.hasOwnProperty.call(targetObj, key)) {
				const sourceVal = sourceObj[key];
				if (sourceVal !== null && sourceVal !== undefined && sourceVal !== '') {
					if (typeof sourceVal === 'object' && Object.prototype.toString.call(sourceVal) !==
						'[object Array]') {
						demandAssign(targetObj[key], sourceVal, isAll);
					} else {
						targetObj[key] = sourceObj[key];
					}
				}
			}
		}
	}
}

// 获取页面URL参数
export function getLocationParams(name) {
	//获取页面栈
	const pages = getCurrentPages();
	//获取路由参数
	const curPage = pages[pages.length - 1];
	return name ? curPage.options[name] : curPage.options;
}